home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12985 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: maverick.tad.eds.com!news-admin@tad.eds.com
  2. From: fignet05.darrins@eds.com (Darrin Smith)
  3. Newsgroups: comp.lang.c++
  4. Subject: A question about serialization and MFC in VC++.
  5. Date: 22 Mar 1996 21:35:12 GMT
  6. Organization: CUSD
  7. Message-ID: <4iv6eg$6qq@maverick.tad.eds.com>
  8. NNTP-Posting-Host: 148.94.222.53
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.93.11
  11.  
  12. First off, thanks for reading.
  13.  
  14. Now, how do you continue to read a document (file) until eof and use 
  15. serialization?
  16.  
  17. I have a serialize function in a class that looks like this:
  18.  
  19. void MyClass::Serialize(CArchive& ar)
  20. {
  21.     TRACE("Entering Graphics::Serialize\n");
  22.     if (ar.IsStoring())    
  23.        {ar << x << y << rad1 << rad2 << type;
  24.        }
  25.     else 
  26.        {ar >> x >> y >> rad1 >> rad2 >> type;
  27.        } 
  28. }
  29.  
  30. How do I call this function for each record in the file?
  31.  
  32. I know I need to do something like:
  33.  
  34.    MyClass *ptr;
  35.  
  36.    ptr=new MyClass();
  37.  
  38.    ptr->Serialize();
  39.  
  40. But this only gets the first record.  I can't seem to get feof to work 
  41. with the CArchive class (as in: while(!(feof(ar))  ).
  42.  
  43. Any help is greatly appreciated.
  44.  
  45. Thanks. 
  46.  
  47.